


*** Figure II ***

clear all

*Set the folder where data are
cd ""

*** Replace MW county data with city or province when possible 
use minwage2_county2
ren county countyid
gen cityid=int(countyid/100)
move cityid countynm
joinby cityid year using "minwage2_city.dta", unmatched(master) update _merge(_merge1)
gen provid  = int(cityid/100)
move provid countynm
joinby provid year using "minwage2_prov.dta", unmatched(master) update _merge(_merge2)
drop countynm name
drop _merge1 _merge2

*** merge with CPI and labr dispute cases
sort provid year
joinby provid year using "prov_cpi_lbcases.dta", unmatched(master)
drop _merge

*** create county control variables
gen realminw=miniwage*12/cpiindex      // annual real minimum wage in 2002 yuan
gen effrealmw=mwminiwage*12/cpiindex   // annual real effective minimum wage in 2002 yuan

*** Effective MW
****************
set more off
sort year countyid
gen ny = emwch
bysort year: replace ny = sum(ny)
bysort year: egen nemwchy = max(ny)
by year: sum nemwchy   // the mean is the number of counties that changed out of total observations in that year

set more off
bysort countyid year: gen ncounties = _n == 1
bysort year: replace ncounties = sum(ncounties)
bysort year: egen ncountyy = max(ncounties)

* generate proportion of counties that changed mw in a given year
gen pemwchy = nemwchy/ncountyy
label var pemwchy "Proportion of counties with change of Effective MW"
by year: sum pemwchy

*twoway bar pemwchy year, barwidth(.7)

*** Real Effective MW
*********************
/*
set more off
xtset countyid year
bysort countyid: gen erealmwgr = (effrealmw-l.effrealmw)/effrealmw if emwch==1
sort year countyid
gen nry = ermwch
bysort year: replace nry = sum(nry)
bysort year: egen nermwchy = max(nry)
by year: sum nermwchy   // the mean is the number of counties that changed out of total observations in that year

gen permwchy = nermwchy/ncountyy
twoway bar permwchy year, barwidth(.7)
*/


***
xtset countyid year
bysort countyid: gen erealmwgr = (effrealmw-l.effrealmw)/effrealmw 
tab year if erealmwgr==.

gen gr1=1 if erealmwgr>0 & erealmwgr<=0.10 & erealmwgr!=. & emwch==1
bysort year: replace gr1 = sum(gr1)
bysort year: egen group1 = max(gr1)
gen gr1sh = group1/ncountyy*pemwchy
by year: sum gr1sh

gen gr2=1 if erealmwgr>0.10 & erealmwgr<=0.20 & erealmwgr!=. & emwch==1
bysort year: replace gr2 = sum(gr2)
bysort year: egen group2 = max(gr2)
gen gr2sh = group2/ncountyy*pemwchy
by year: sum gr2sh

gen gr3=1 if erealmwgr>0.20 & erealmwgr!=. & emwch==1
bysort year: replace gr3 = sum(gr3)
bysort year: egen group3 = max(gr3)
gen gr3sh = group3/ncountyy*pemwchy
by year: sum gr3sh

gen gr0=1 if erealmwgr<0 & erealmwgr!=. & emwch==1
bysort year: replace gr0 = sum(gr0)
bysort year: egen group0 = max(gr0)
gen gr0sh = group0/ncountyy*pemwchy
by year: sum gr0sh


graph bar gr0sh gr1sh gr2sh gr3sh, over(year, label(angle(45) labsize(vsmall))) stack ///
title("Counties Minimum Wage Variation 1992-2012") graphregion(color(white)) ///
ytitle("Counties with change in nominal MW, share") ///
bar(1, color(red) fintensity(inten40)  lcolor(none)) bar(2, color(ltblue) fintensity(inten30) lcolor(none)) ///
bar(3, color(ltblue) lcolor(none)) bar(4, color(navy) fintensity(inten50)  lcolor(none)) ///
legend(subtitle("Real MW change") label(1 "{&Delta} {&le} 0%") label(2 "0% {&le} {&Delta} {&le} 10%") ///
label(3 "10% {&le} {&Delta} {&le} 20%") label(4 "{&Delta} {&gt} 20%"))



